package com.ynkbny.tasks;

import com.ynkbny.aspect.TaskOperationLog;
import com.ynkbny.service.BaseJob;
import com.ynkbny.service.LaoGouApiService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 批量新增数据 PlanData
 *
 * @author : juzipi123
 * @date : 2023-8-23
 */
@Slf4j
@Component
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@ConditionalOnProperty(name = "schedule.enabled", havingValue = "false")
public class SavePlanDatas implements BaseJob {

    @Resource
    private LaoGouApiService service;

    /**
     * 批量新增数据 PlanData
     *
     * @author : juzipi123
       0 15 10 * * ?    每天上午10:15触发
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    @TaskOperationLog(description = "批量新增数据 PlanData")
    public void execute(JobExecutionContext jobExecutionContext){
        log.info("自动任务：‘批量新增数据 PlanData’ 开始");
        service.savePlanDatas();
        log.info("自动任务：‘批量新增数据 PlanData’ 结束");
    }
}
